package oc_validate

import (
	"oc_saas/internal/glo"
	validate_type "oc_saas/internal/types/validate"
	"oc_saas/internal/utils"

	"github.com/go-playground/validator/v10"
)

type ocValidator struct{}

// 初始化自定义验证
func (*ocValidator) InitValidator() {
	validate := validator.New()
	validate.RegisterValidation("password", utils.GloValidStr(validate_type.PASSWORD)) //密码校验
	validate.RegisterValidation("username", utils.GloValidStr(validate_type.USERNAME)) //用户名校验
	validate.RegisterValidation("ocPerms", utils.GloValidStr(validate_type.PERMS))     //权限标识校验
	validate.RegisterValidation("ocName", utils.GloValidStr(validate_type.Name))       //权限路由名称
	validate.RegisterValidation("ocPath", utils.GloValidStr(validate_type.Path))       //权限路径
	validate.RegisterValidation("ocReqType", utils.GloValidStr(validate_type.ReqType)) //请求类型
	validate.RegisterValidation("ocVue", utils.GloValidStr(validate_type.Vue))         //vue组件文件路径
	glo.OC_VALID = validate
}

var OcValidatorApp = new(ocValidator)
